<template>
	<view class="root">
		<y-seat height="30"></y-seat>
		<header-title
			:title="isClock?'点我跳过':'发布你的内容吧'"
			@clickTitle="clickTitle"
			:isPoint="true"
			pointColor="#7D6AED"
			:isBtn="true"
			:btnStyle="customStyle"
			@clickBtn="clickBtn"
		></header-title>
		<view class="content Limit">
				<view style="margin: 15rpx;">
					<u-input v-model="form.content" :auto-height="false" type="textarea" maxlength="1000" height="300" placeholder="想说你就多说点" :border="false" /></u-form-item>
					<view style="color: #C0C4CC;">
						<text>{{form.content.length}}/1000</text>
					</view>
				</view>
				<u-upload 
					:action="action"
					:header="header" 
					:upload-text="type=='video'?'选择视频':'选择图片'" 
					:max-count="type=='video'?1:9"
					:limitType="limitType"
					@on-success="uploadSuccess"
					:before-upload="beforeUpload"
					v-if="type=='image'"
					@on-error="onImageError"
					:show-tips="false"
					></u-upload>
				<u-cell-group>
					<!-- <u-cell-item title="添加地点" @click="addAddress" :arrow="false">
						<text class="iconfont icondingwei" slot="icon" style="margin-right: 10rpx;"></text>
						<text slot="right-icon">{{address}}</text>
					</u-cell-item> -->
					<u-cell-item title="选择计划" @click="changePlanClick">
						<text slot="icon" style="margin-right: 10rpx;">
							<u-icon  name="bookmark"></u-icon>
						</text>
						<text slot="right-icon">{{planName}}</text>
					</u-cell-item>
					<u-cell-item title="设置权限" @click="changeGroup" :arrow="false">
						<text slot="icon" style="margin-right: 10rpx;">
							<u-icon  name="setting"></u-icon>
						</text>
						<text slot="right-icon">{{group.length>0?group[okGroup]:''}}</text>
						<u-picker v-model="show" mode="selector" :range="group"   @confirm="confirm"></u-picker>
					</u-cell-item>
				</u-cell-group>
		</view>
		
		<u-tabbar :list="vuex_tabbar" :mid-button="true" @change="clickTabbar" :current="0"></u-tabbar>
	</view>
</template>

<script>
import {mapState, mapMutations} from 'vuex';
import {config} from "../../config/config";
export default {
	data() {
		return {
			customStyle: {
				backgroundColor: '#5466ff',
				marginRight: '30rpx'
			},
			form: {
				content: '',
				checked: false
			},
			header:{
				token:uni.getStorageSync('token')||"test"
			},
			type:"image",
			limitType:['png', 'jpg', 'jpeg', 'webp', 'gif'],
			action:config.apiBaseUrl+'v1/file/uploadFile',
			fileList: [
				
			],
			group:["所有人可见","仅朋友可见","仅自己可见"],
			show:false,
			okGroup:0,
			planName:"",
			isClock:false
		}
	},
	computed: {
		...mapState(['vuex_tabbar'])
	},
	onLoad(e) {
		if(e.info){
			const plan = JSON.parse(e.info);
			this.planName = plan.planName;
			this.isClock=true;
			console.log(plan)
		}
		
	},
	mounted() {
		console.log(this.vuex_tabbar)
	},
	methods: {
		clickBtn(){
			uni.showToast({
				title:"打卡成功"
			})
			setTimeout(()=>{
				uni.reLaunch({
					url:'/pages/index/index'
				})
			},1000)
		},
		clickTitle(){
			if(this.isClock){
				uni.showToast({
					title:"打卡成功"
				})
				setTimeout(()=>{
					uni.reLaunch({
						url:'/pages/index/index'
					})
				},1000)
			}
		},
		clickTabbar(){
			console.log(123)
		},
		beforeUpload(){
			uni.showLoading({
				title:"上传中",
				icon:"none",
				mask:true
			})
		},
		//视频上传成功
		uploadData(e){
			this.uploadVideo=e;
			console.log(e);
		},
		confirm(e){
			this.okGroup=e;
		},
		changeGroup(){
			this.show=!this.show;
		},
		changePlanClick(){
			uni.navigateTo({
				url:"./plan-change"
			})
		}
	}
}
</script>

<style lang="scss">

</style>
